<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCommentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('comments', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->bigIncrements('id');
            $table->bigInteger('post_id')->default(0)->comment('文章表外键');
            $table->bigInteger('user_id')->default(0)->comment('用户表外键');
            $table->text('content')->comment('留言内容');
            $table->integer('created_at')->default(0)->comment('留言时间');
            $table->integer('updated_at')->default(0)->comment('留言修改时间');
            $table->index('post_id');
            $table->index('user_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('comments');
    }
}
